package com.ywz.framework.minio;

import com.ywz.common.SymmetricAlgorithmUtils;
import com.ywz.framework.property.MinioProperties;
import io.minio.MinioClient;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 类描述 -> minio配置类
 *
 * @Author: ywz
 * @Date: 2025/02/11
 */
@Configuration
@AllArgsConstructor
public class MinioConfig {

    private final MinioProperties minioProperties;

    /**
     * 方法描述 -> 获取minio客户端minio客户端
     *
     * @Author: ywz
     * @Date: 2025/02/11
     */
    @Bean
    public MinioClient getMinioClient() {
        return MinioClient.builder()
                .endpoint(SymmetricAlgorithmUtils.decrypt(minioProperties.endpoint()))
                .credentials(SymmetricAlgorithmUtils.decrypt(minioProperties.accessKey())
                        , SymmetricAlgorithmUtils.decrypt(minioProperties.secretKey()))
                .build();
    }
}
